package com.filepublic.demo.server.controller;

import com.filepublic.demo.common.annotations.PropertyNotNull;
import com.filepublic.demo.common.context.ThreadLocalContext;
import com.filepublic.demo.common.result.Result;
import com.filepublic.demo.pojo.dto.PenPalDto;
import com.filepublic.demo.pojo.entity.PenPalEntity;
import com.filepublic.demo.pojo.vo.PenPalVo;
import com.filepublic.demo.server.service.PenPalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "笔友控制器")
@RestController
@RequestMapping("/penpal")
public class PenPalController {

    @Resource
    PenPalService penPalService;

    /**
     * 笔友信息
     * @return
     */
    @GetMapping("/info")
    @ApiOperation(value = "笔友信息")
    public Result<List<PenPalVo>> penPalInfo(){
        List<PenPalVo> penPalVo = penPalService.penPalInfo();
        return Result.success(penPalVo);
    }

    /**
     * 添加笔友
     * @param penPalDto
     * @return
     */
    @PropertyNotNull
    @ApiOperation(value = "添加笔友")
    @PostMapping("/add")
    public Result penPalAdd(@RequestBody PenPalDto penPalDto){
        penPalService.penPalAdd(penPalDto);
        return Result.success();
    }
}

















